<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="Public/Home/css/car_1.css"/>
		<link rel="stylesheet" type="text/css" href="Public/Home/css/index.css"/>
		<link rel="stylesheet" href="Public/Home/css/animate.css">
		<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
		<script src="Public/Home/js/car.js" type="text/javascript" charset="utf-8"></script>
		<title>购物车第一步</title>
	</head>
	<body>
		<!--公共的头部开始-->

		<!--头部公共头部-->
		<div id="top">
			<div class="mid">
				<div class="left">
					<a href="<?php echo U('Index/index')?>" class="huaWe">大雷官网</a>
					
					<div class="softUser">
						
					</div>
					
				</div>
				<div class="right">
					<div class="webNav">
				
					</div>
					<?php if($userData){?>
						<a href="<?php echo U('Person/index',['uid'=>$userData['uid']])?>"><?php echo $userData['username']?></a>
						<a href="<?php echo U('Login/out')?>">退出</a>

						<a href="<?php echo U('Person/index',['uid'=>$userData['uid']])?>">我的订单</a>
					<?php }else{?>

						<a href="<?php echo U('Login/register')?>">注册</a>
						<a href="<?php echo U('Login/index')?>">登录</a>

						<a href="<?php echo U('Login/index')?>">我的订单</a>
					<?php }?>

				</div>
			</div>
		</div>
		<!--公共头部结束-->
		
		
		
		
		<!--公共的头部结束-->
		
		
		
		
		
		
		<!--标题部分-->
		<div id="car_title">
			<div class="new_logo">
				<ul>

				</ul>
			</div>
		</div>
		<!--标题部分结束-->
		<!--内容部分-->
		<?php if($introData){?>


			
		<div id="car_content">
			<div class="top">
				<input type="checkbox" class="check_all check_box" i='0'  checked="" onclick="setCheck(this)"/>
				<span class="goods_name">商品</span>
				<span class="every_money">单价(元)</span>
				<span class="how_much">数量</span>
				<span class="total">小计(元)</span>
				<span class="happen">操作</span>
			</div>
			
				
			<div class="mid">
				<?php foreach ($introData as $k=>$v){?>
				
				<div class="mid_goods">
					<input type="checkbox" class="check_one checkbox_qx  biaoji" i='0' checked=""  onclick="setCheckQx(this)" />
					<img src="<?php echo $v['pic']?>" class="you_goods"/>
					<a href="<?php echo U('Detail/index',['gid'=>$v['gid']])?>" class="title"><?php echo $v['gname']?> &nbsp;&nbsp;<?php echo $v['desc']?></a>
					<span class="goods_color">
						<?php foreach ($v['tempSpec'] as $vv){?>
							<span><?php echo $vv?>&nbsp;</span>
						<?php }?>
					</span>
					<span class="goods_send">此商品由华为终端发货</span>
					
					<span class="spand">¥<span><?php echo $v['gwc']['price']?></span></span>

					<div class="much_goods">
						<a href="javascript:;" class="up up_ps"></a>
						<input type="text" name="" class="up_ps_num" value="<?php echo $v['gwc']['num']?>"  disabled="true" style="text-align:center" />				
						<a href="javascript:;" class="down up_ps"></a>
						
					</div>

					<div class="total">
						
							¥<i class="wori"><?php echo $v['gwc']['total']?></i>.00
					</div>
					<div class="del"   value="<?php echo $k?>">
						×
					</div>
				</div>
				<?php }?>			
			</div>
		
		</div>
	<!--内容部分结束-->
		
		<!--底部开始-->
		
		<div id="bot_goods" style="position:relative"> 
			<input type="checkbox" class="check_box" name="" id="" value=""  i='0' checked=""  onclick="setCheck(this)"/>
			<span class="check_all check_box" id="panduanqx" i="0"   checked="" onclick="setCheck(this)">全选</span>
			<span class="del_check"  onclick="$('#qrsc').show()">删除选中的商品</span>
			<!-- 点击删除的时候跳出的确认框 -->
			<div id="qrsc"  style="position:absolute; z-index: 999; width:400px;height:200px;background-color:#F2F2F2; margin:10px;display:none">
	
					<center>
						<div style="margin:20px">
							<p style="font-size:20px;margin:50px">您真的确认删除吗</p>
							<span href="javascript:;" id="del_sp"  style="display: inline-block; width:100px;height:30px;background-color:#E01D20;text-align:center;line-height:30px;font-size:15px;color:white;cursor:pointer" >确认删除</span>
							<span class="" href="javascript:;"  style="display: inline-block; width:100px;height:30px;background-color:#009323;text-align:center;line-height:30px;font-size:15px;color:white;cursor:pointer;margin-left:10px" onclick="$('#qrsc').hide()">撤回</span>
							</p>			
						</div>
					</center>

						
				</div>
			

			<div class="right_check">
				<span class="all_youMoney" >总计金额：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¥<i id="zje"><?php echo $gwcData['total']?></i>.00</span>
				<span>共节省:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¥0.00</span>
				<span   id="">合计(不含运费):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;¥<i id="hj"><?php echo $gwcData['total']?></i>.00</span>
			</div>
			
		</div>
		<!--底部结束-->
		<div id="buy">
			<a href="<?php echo U('Index/index')?>" class="continue">继续购物</a>
			<?php if(isset($_SESSION['info'])){?>
			<a href="javascript:;" class="goBy">去结算</a>
			<?php }else{?>
			<a href="<?php echo U('Login/index')?>" class="goBy">去结算</a>
			<?php }?>
		
		</div>
		
		<script  type="text/javascript" >

			function setCheck(myself){
				var i=$(myself).attr('i');
				if(i==1){
					// alert(i);
					$('.checkbox_qx').prop('checked',true);
					$('.checkbox_qx').addClass('biaoji');
					$('.check_box').prop('checked',true);

					$('.check_box').attr('i',0);
				}else{
					// alert(i);
					$('.checkbox_qx').prop('checked',false);
					$('.checkbox_qx').removeClass('biaoji');
					$('.check_box').prop('checked',false);
					$('.check_box').attr('i',1);
				}
			}	


			function setCheckQx(myself){
				var i=$("#panduanqx").attr("i");
				var s=$(myself).attr('i');

				if(s==0){
					$(myself).prop('checked',false);
					$(myself).removeClass('biaoji');
					$(myself).attr('i','1');
				}else{
					$(myself).prop('checked',true);
					$(myself).addClass('biaoji');
					$(myself).attr('i','0');
				}
				var len=$(".biaoji").length;
				if(len!=$('.checkbox_qx').length){
					$('.check_box').prop('checked',false);
					$('.check_box').attr('i',1);
				}else{
					$('.check_box').prop('checked',true);
					$('.check_box').attr('i',0);
				}
				
			}




			$(function(){
				// 方法①，ajax方法
				$('.del').click(function(){
					var glid=$(this).attr('value');
					$.ajax({
					  type: "post",
					  url: "<?php echo U('Gwc/oneAjax')?>",
					  data:{glid},
					  dataType: "json",
					  success:function(phpData){

					  	if(phpData==0){
					  		$('#car_content').remove();
					  		$('$bot_goods').remove();
					  		var temp='';
					  		temp+="<div id='car_content'><div class='top'><input type='checkbox' class='check_all'/>";
					  		temp+="<span class='goods_name'>商品</span><span class='every_money'>单价(元)</span>";	
					  		temp+="<span class='how_much'>数量</span><span class='total'>小计(元)</span>";
					  		temp+="<span class='happen'>操作</span></div><div style='margin-bottom:200px'>";		
							temp+="<center><h1 style='color:#FC1F0F'></h1><p style='font-size:100px;color:#999999'>&Theta;   &Theta;</p><p style='font-size:50px;color:#999999'>&cap;</p><p style='font-size:30px;color:#6BD300;'>请去选择商品</p></center></div></div>";						

					  		$('#car_title').after(temp);
					  		return;
					  	}
					  	$('#zje').html(phpData.total);
					  	$('#hj').html(phpData.total);
					  }


					});
				})


				// 方法②,ajax,点击数量变化的时候，发起异步
				$('.up_ps').click(function(){
					var num=$(this).siblings('.up_ps_num').val();
					var glid=$(this).parent().siblings(".del").attr('value');
					$.ajax({
						// 这里的类型一定要大小，否则出错
					    type: "POST",
					    url: "<?php echo U('Gwc/twoAjax')?>",
					    data:{glid,num},
					    dataType: "json",
					    success:function(phpData){
					    
				  		  	$('#zje').html(phpData.total);
		  				 	$('#hj').html(phpData.total);
					  }
					});
				})



				// 方法③，点击删除选择项触发异步

				$('#del_sp').click(function(){
					$('.biaoji').each(function(i,k){



					})

					$('.biaoji').parent().hide();
					$('#qrsc').hide();
					




				})

				// 点击去结算的时候，给 a标签添加的click事件
				$('.goBy').click(function(){
					var len=$('.biaoji').length;
					if(len==0){
						alert('请选择有效商品');
						return;
					}
					var temp='';
					$('.biaoji').each(function(){
						 temp+=$(this).siblings('.del').attr('value')+'|';

					})
					location.href="<?php echo U('Gwc/carTwo')?>&tempnam="+temp;
				})


			})	

			


		</script>
		



			
		<?php }else{?>


			<div id="car_content">
				<div class="top">
					<input type="checkbox" class="check_all"/>
					<span class="goods_name">商品</span>
					<span class="every_money">单价(元)</span>
					<span class="how_much">数量</span>
					<span class="total">小计(元)</span>
					<span class="happen">操作</span>
				</div>
				<div style="margin-bottom:200px">
					<center><h1 style="color:#FC1F0F"></h1>
							<p style="font-size:100px;color:#999999" class="animated flash"><span  >&Theta;</span>  <span>&Theta;</span></p>
							<p style="font-size:50px;color:#999999"  class="animated fadeInLeftBig">&cap;</p>
							<p style="font-size:30px;color:#6BD300;" i='0' class="ps">请去选择商品</p>
					</center>
					
				</div>
				
			</div>
			<script  type="text/javascript">

		// 你妹啊，这个jquery的标志写和不写对其中内容没啥影响
				  function ppd(){
				 	if($('.ps').attr('i')==0){
				 		$('.ps').css('color','red');
				 		$('.ps').attr('i','1');
				 	}else{
				 		$('.ps').css('color','#6BD300');
				 		$('.ps').attr('i','0');
				 	}
				 
				 }
				 setInterval("ppd()",1500);

			</script>
		<?php }?>
		
		
		<!--公共的尾部-->
		
		<!--结束条幅-->
		<!--<a href="" id="lastAd"></a>-->
		<!--结束条幅结束-->
		
		<!--微信qq微博手机客户端-->
		<div id="contentWe">
			
		</div>
		<div id="xian">
				
		</div>
		<div id="aboutWe">
			<p>
				<i class="iconfont">&#xe600;</i>
				<span>500强企业 品质保证</span>
			</p>
			<p>
				<i class="iconfont">&#xe691;</i>
				<span>7天退货 15天换货</span>
			</p>
			<p>
				<i class="iconfont">&#xf0082;</i>
				<span>99元起免运费</span>
			</p>
			<p>
				<i class="iconfont">&#xe62a;</i>
				<span>448家维修网点 全国联保</span>
			</p>
		</div>
		<!--微信qq微博手机客户端结束-->
		<!--站点公告-->
		<div id="webSet">
			<span>Copyright © 2012-2016 ****** 版权所有 保留一切权利</span>
			<div class="webOne">
				<ul>
					<li>******** 32011402010009号</li>
					<li>*******09062682号-9</li>
					<li>********经营许可证：苏B2-20130048</li>
					<li>******经营许可证：苏网文[2012]0401-019号</li>
				</ul>
				
			</div>
		</div>
		<!--站点公告结束-->
		<div id="lastImg"><!-- 
			<img src="Public/Home/images/b1.png" alt="" />
			<img src="Public/Home/images/d.png" alt="" />
			<img src="Public/Home/images/到.png" alt="" /> -->
		</div>
		
		
		
		
		<!--公共的尾部结束-->
		
		
	</body>
</html>






























